import { MessageBox } from "element-ui";
import { OSS_URL } from "../contanst/url";
import request from "../utils/request"

function FetchProductDetails(params, component) {
  return request({
    url:'/productDetail/getProductdetails',
    method:'post',
    data:{
      id: params
    }
  }).then(res => {
    // console.log("component", component);
    component.$data.list = res.data.items;
    component.$data.startTokenId = res.data.startTokenId;
    component.value.startToken = res.data.startTokenId
    component.value.productItems = res.data.items
    component.$data.listLoading = false;
    return res.data;
  });
}

function FetchProductDetailsList(params, component) {
  return request({
    url:'/productDetail/lookSeriesNft',
    method:'post',
    data: params
  }).then(res => {
    // console.log("component", component);

    res.data.data.forEach(res => {
      res.pictures = OSS_URL + res.pictures;
    })
    component.$data.list = res.data.data;
    component.$data.total = res.data.total;
    component.$data.listLoading = false;
    return res.data;
  });
}

function PublishStatus(params, component) {
  return request.post("/productDetail/publishStatus", params).then(response => {
   MessageBox({
      message: '修改成功',
      type: 'success',
      duration: 1000
    });
  });
}

function UpdateShopwindow(params, component) {
  return request.post("/productDetail/updateShopwindow", params).then(response => {
    MessageBox({
      message: '修改成功',
      type: 'success',
      duration: 1000
    });
  });
}

export {
  FetchProductDetails,
  PublishStatus,
  UpdateShopwindow,
  FetchProductDetailsList
}